plots

Row

Number of penguins

344

Avg body mass

Column

Scatter plot of bill length vs bill depth

Chart B

Chart C

data

---
title: "Dashboarding Demo"
output: 
  flexdashboard::flex_dashboard:
    orientation: row  #another option is columns
    vertical_layout: fill
    social: ["menu"] #to have links to social media
    source_code: embed #link to get source code
    theme:
      version: 4
      bootswatch: spacelab #see bootswatch.com site for other themes
---

```{r, include=FALSE}
# RStudio 2021.09.0+351 "Ghost Orchid" Release 
# (077589bcad3467ae79f318afe8641a1899a51606, 2021-09-20) for Windows
# Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) 
# QtWebEngine/5.12.8 Chrome/69.0.3497.128 Safari/537.36 
```


```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(palmerpenguins)
library(plotly)
library(DT)
library(fontawesome)
#load data from palmerpenguins
data("penguins")
head(penguins)
```

plots {data-navmenu="Pages"}
======================================================================

Sidebar {.sidebar}
-------------------------------------------------------------------

### Penguin Stats

The number of penguins in the data is `r nrow(penguins)`



Row
-------------------------------------------------------------------

### Number of penguins
```{r}
valueBox(nrow(penguins), icon = "fa-linux") #font awesome icon
```

### Avg body mass

```{r}
avg_mass = round(mean(penguins$body_mass_g, na.rm = T), 1)
gauge(avg_mass, 
      min(0),
      max = max(penguins$body_mass_g, na.rm = T),
      gaugeSectors(success = c(4000, 6300),
                   warning = c(2000, 3999),
                   danger = c(0, 1999)))
```


Column {.tabset}
-----------------------------------------------------------------------

### Scatter plot of bill length vs bill depth

```{r}
a = penguins %>% ggplot(aes(x = bill_length_mm, y = bill_depth_mm, color = species))+
  geom_point()
ggplotly(a)
#htmlwidgets.org & Showcase for more html options; try leaflet (interactive maps)
# -also check the Gallery for registered widgets to try
```


### Chart B

```{r}
penguins %>% ggplot(aes(x = body_mass_g, y = sex, fill = sex))+
  geom_boxplot()
```

### Chart C

```{r}
penguins %>% ggplot(aes(x = flipper_length_mm, fill = species))+
  geom_histogram()+
  facet_wrap(~species)
```


data {data-navmenu="Pages"}
=========================================================================

```{r}
penguins %>% datatable(extensions = "Buttons", 
                       options = list(dom = "Blfrtip",
                                      buttons = c("copy", "csv", "excel",
                                                  "pdf", "print")))
#B for Buttons, l for length, t for table, p for pagination, f for _, r for _, i for _
# lfrtip is the default
#Go to datatables.net to see all options to customize html table

```